<template>
	<view>
		<form>
			<view class="cu-form-group margin-top">
				<view class="title">新密码</view>
				<input v-model="newpass" placeholder="请输入" name="input"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">确认密码</view>
				<input v-model="newpass2" placeholder="请输入" name="input"></input>
			</view>
			<view class="padding ">
				<button class="cu-btn block bg-blue margin-sm lg" @tap="sure">确认</button>
			</view>
		</form>
	</view>
</template>

<script>
	import {getxgmm} from '../api/api.js'
	export default {
		data() {
			return {
				newpass:'',
				newpass2:''
			}
		},
		methods:{
			sure() {
				console.log(this.newpass,this.newpass2)
				if((this.newpass==''&&this.newpass2=='')||(this.newpass!==this.newpass2)||(this.newpass.length<6)){
					uni.showModal({
					    title: '提示',
					    content: '两次输入密码要一致，并且长大于6位',
						showCancel:false
					});
				}else{
					var name = uni.getStorageSync('useID');
					let parm={
						username:name,
						password:this.newpass
					}
					getxgmm(parm,
						res=>{
							uni.showModal({
							    title: '提示',
							    content: res.data.returnMsg,
								showCancel:false
							});
							if(res.data.returnCode==200){
								uni.setStorage({//将用户信息清空
									key: 'useID',
									data: ''
								})
							}
						}
					)
				}
			}
		}
	}
</script>

<style>
	@import "../../colorui/main.css";
	@import "../../colorui/icon.css"; 
</style>
